home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / gnu / emacs_src_18_58.lha / emacs-18.58 / info / emacs-8 (.txt) < prev    next >
GNU Info File  |  1992-02-21  |  46KB  |  824 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.43 from the
  2. input file emacs.tex.
  3.    This file documents the GNU Emacs editor.
  4.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.
  5.    Permission is granted to make and distribute verbatim copies of
  6. this manual provided the copyright notice and this permission notice
  7. are preserved on all copies.
  8.    Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided also
  10. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  11. General Public License" are included exactly as in the original, and
  12. provided that the entire resulting derived work is distributed under
  13. the terms of a permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that the sections entitled "The GNU Manifesto",
  17. "Distribution" and "GNU General Public License" may be included in a
  18. translation approved by the author instead of in the original English.
  19. File: emacs,  Node: Lisp Completion,  Next: Documentation,  Prev: Balanced Editing,  Up: Programs
  20. Completion for Lisp Symbols
  21. ===========================
  22.    Usually completion happens in the minibuffer.  But one kind of
  23. completion is available in all buffers: completion for Lisp symbol
  24. names.
  25.    The command `M-TAB' (`lisp-complete-symbol') takes the partial Lisp
  26. symbol before point to be an abbreviation, and compares it against all
  27. nontrivial Lisp symbols currently known to Emacs.  Any additional
  28. characters that they all have in common are inserted at point. 
  29. Nontrivial symbols are those that have function definitions, values or
  30. properties.
  31.    If there is an open-parenthesis immediately before the beginning of
  32. the partial symbol, only symbols with function definitions are
  33. considered as completions.
  34.    If the partial name in the buffer has more than one possible
  35. completion and they have no additional characters in common, a list of
  36. all possible completions is displayed in another window.
  37. File: emacs,  Node: Documentation,  Next: Change Log,  Prev: Lisp Completion,  Up: Programs
  38. Documentation Commands
  39. ======================
  40.    As you edit Lisp code to be run in Emacs, the commands `C-h f'
  41. (`describe-function') and `C-h v' (`describe-variable') can be used to
  42. print documentation of functions and variables that you want to call. 
  43. These commands use the minibuffer to read the name of a function or
  44. variable to document, and display the documentation in a window.
  45.    For extra convenience, these commands provide default arguments
  46. based on the code in the neighborhood of point.  `C-h f' sets the
  47. default to the function called in the innermost list containing point.
  48.  `C-h v' uses the symbol name around or adjacent to point as its
  49. default.
  50.    Documentation on Unix commands, system calls and libraries can be
  51. obtained with the `M-x manual-entry' command.  This reads a topic as an
  52. argument, and displays the text on that topic from the Unix manual. 
  53. `manual-entry' always searches all 8 sections of the manual, and
  54. concatenates all the entries that are found.  For example, the topic
  55. `termcap' finds the description of the termcap library from section 3,
  56. followed by the description of the termcap data base from section 5.
  57. File: emacs,  Node: Change Log,  Next: Tags,  Prev: Documentation,  Up: Programs
  58. Change Logs
  59. ===========
  60.    The Emacs command `M-x add-change-log-entry' helps you keep a record
  61. of when and why you have changed a program.  It assumes that you have a
  62. file in which you write a chronological sequence of entries describing
  63. individual changes.  The default is to store the change entries in a
  64. file called `ChangeLog' in the same directory as the file you are
  65. editing.  The same `ChangeLog' file therefore records changes for all
  66. the files in the directory.
  67.    A change log entry starts with a header line that contains your
  68. name and the current date.  Aside from these header lines, every line
  69. in the change log starts with a tab.  One entry can describe several
  70. changes; each change starts with a line starting with a tab and a
  71. star.  `M-x add-change-log-entry' visits the change log file and
  72. creates a new entry unless the most recent entry is for today's date
  73. and your name.  In either case, it adds a new line to start the
  74. description of another change just after the header line of the entry.
  75.  When `M-x add-change-log-entry' is finished, all is prepared for you
  76. to edit in the description of what you changed and how.  You must then
  77. save the change log file yourself.
  78.    The change log file is always visited in Indented Text mode, which
  79. means that LFD and auto-filling indent each new line like the previous
  80. line.  This is convenient for entering the contents of an entry, which
  81. must all be indented.  *Note Text Mode::.
  82.    Here is an example of the formatting conventions used in the change
  83. log for Emacs:
  84.      Wed Jun 26 19:29:32 1985  Richard M. Stallman  (rms at mit-prep)
  85.      
  86.              * xdisp.c (try_window_id):
  87.              If C-k is done at end of next-to-last line,
  88.              this fn updates window_end_vpos and cannot leave
  89.              window_end_pos nonnegative (it is zero, in fact).
  90.              If display is preempted before lines are output,
  91.              this is inconsistent.  Fix by setting
  92.              blank_end_of_window to nonzero.
  93.      
  94.      Tue Jun 25 05:25:33 1985  Richard M. Stallman  (rms at mit-prep)
  95.      
  96.              * cmds.c (Fnewline):
  97.              Call the auto fill hook if appropriate.
  98.      
  99.              * xdisp.c (try_window_id):
  100.              If point is found by compute_motion after xp, record that
  101.              permanently.  If display_text_line sets point position wrong
  102.              (case where line is killed, point is at eob and that line is
  103.              not displayed), set it again in final compute_motion.
  104. File: emacs,  Node: Tags,  Next: Fortran,  Prev: Change Log,  Up: Programs
  105. Tag Tables
  106. ==========
  107.    A "tag table" is a description of how a multi-file program is broken
  108. up into files.  It lists the names of the component files and the
  109. names and positions of the functions in each file.  Grouping the
  110. related files makes it possible to search or replace through all the
  111. files with one command.  Recording the function names and positions
  112. makes possible the `Meta-.' command which you can use to find the
  113. definition of a function without having to know which of the files it
  114. is in.
  115.    Tag tables are stored in files called "tag table files".  The
  116. conventional name for a tag table file is `TAGS'.
  117.    Each entry in the tag table records the name of one tag, the name
  118. of the file that the tag is defined in (implicitly), and the position
  119. in that file of the tag's definition.
  120.    Just what names from the described files are recorded in the tag
  121. table depends on the programming language of the described file.  They
  122. normally include all functions and subroutines, and may also include
  123. global variables, data types, and anything else convenient.  In any
  124. case, each name recorded is called a "tag".
  125. * Menu:
  126. * Tag Syntax::
  127. * Create Tag Table::
  128. * Select Tag Table::
  129. * Find Tag::
  130. * Tags Search::
  131. * Tags Stepping::
  132. * List Tags::
  133. File: emacs,  Node: Tag Syntax,  Next: Create Tag Table,  Prev: Tags,  Up: Tags
  134. Source File Tag Syntax
  135. ----------------------
  136.    In Lisp code, any function defined with `defun', any variable
  137. defined with `defvar' or `defconst', and in general the first argument
  138. of any expression that starts with `(def' in column zero, is a tag.
  139.    In C code, any C function is a tag, and so is any typedef if `-t' is
  140. specified when the tag table is constructed.
  141.    In Fortran code, functions and subroutines are tags.
  142.    In LaTeX text, the argument of any of the commands `\chapter',
  143. `\section', `\subsection', `\subsubsection', `\eqno', `\label',
  144. `\ref', `\cite', `\bibitem' and `\typeout' is a tag.
  145. File: emacs,  Node: Create Tag Table,  Next: Select Tag Table,  Prev: Tag Syntax,  Up: Tags
  146. Creating Tag Tables
  147. -------------------
  148.    The `etags' program is used to create a tag table file.  It knows
  149. the syntax of C, Fortran, LaTeX, Scheme and Emacs Lisp/Common Lisp.  To
  150. use `etags', type
  151.      etags INPUTFILES...
  152. as a shell command.  It reads the specified files and writes a tag
  153. table named `TAGS' in the current working directory.  `etags'
  154. recognizes the language used in an input file based on its file name
  155. and contents; there are no switches for specifying the language.  The
  156. `-t' switch tells `etags' to record typedefs in C code as tags.
  157.    If the tag table data become outdated due to changes in the files
  158. described in the table, the way to update the tag table is the same
  159. way it was made in the first place.  It is not necessary to do this
  160. often.
  161.    If the tag table fails to record a tag, or records it for the wrong
  162. file, then Emacs cannot possibly find its definition.  However, if the
  163. position recorded in the tag table becomes a little bit wrong (due to
  164. some editing in the file that the tag definition is in), the only
  165. consequence is to slow down finding the tag slightly.  Even if the
  166. stored position is very wrong, Emacs will still find the tag, but it
  167. must search the entire file for it.
  168.    So you should update a tag table when you define new tags that you
  169. want to have listed, or when you move tag definitions from one file to
  170. another, or when changes become substantial.  Normally there is no
  171. need to update the tag table after each edit, or even every day.
  172. File: emacs,  Node: Select Tag Table,  Next: Find Tag,  Prev: Create Tag Table,  Up: Tags
  173. Selecting a Tag Table
  174. ---------------------
  175.    Emacs has at any time one "selected" tag table, and all the commands
  176. for working with tag tables use the selected one.  To select a tag
  177. table, type `M-x visit-tags-table', which reads the tag table file
  178. name as an argument.  The name `TAGS' in the default directory is used
  179. as the default file name.
  180.    All this command does is store the file name in the variable
  181. `tags-file-name'.  Emacs does not actually read in the tag table
  182. contents until you try to use them.  Setting this variable yourself is
  183. just as good as using `visit-tags-table'.  The variable's initial
  184. value is `nil'; this value tells all the commands for working with tag
  185. tables that they must ask for a tag table file name to use.
  186. File: emacs,  Node: Find Tag,  Next: Tags Search,  Prev: Select Tag Table,  Up: Tags
  187. Finding a Tag
  188. -------------
  189.    The most important thing that a tag table enables you to do is to
  190. find the definition of a specific tag.
  191. `M-. TAG'
  192.      Find first definition of TAG (`find-tag').
  193. `C-u M-.'
  194.      Find next alternate definition of last tag specified.
  195. `C-x 4 . TAG'
  196.      Find first definition of TAG, but display it in another window
  197.      (`find-tag-other-window').
  198.    `M-.' (`find-tag') is the command to find the definition of a
  199. specified tag.  It searches through the tag table for that tag, as a
  200. string, and then uses the tag table info to determine the file that the
  201. definition is in and the approximate character position in the file of
  202. the definition.  Then `find-tag' visits that file, moves point to the
  203. approximate character position, and starts searching ever-increasing
  204. distances away for the the text that should appear at the beginning of
  205. the definition.
  206.    If an empty argument is given (just type RET), the sexp in the
  207. buffer before or around point is used as the name of the tag to find. 
  208. *Note Lists::, for info on sexps.
  209.    The argument to `find-tag' need not be the whole tag name; it can be
  210. a substring of a tag name.  However, there can be many tag names
  211. containing the substring you specify.  Since `find-tag' works by
  212. searching the text of the tag table, it finds the first tag in the
  213. table that the specified substring appears in.  The way to find other
  214. tags that match the substring is to give `find-tag' a numeric
  215. argument, as in `C-u M-.'; this does not read a tag name, but
  216. continues searching the tag table's text for another tag containing
  217. the same substring last used.  If you have a real META key, `M-0 M-.'
  218. is an easier alternative to `C-u M-.'.
  219.    Like most commands that can switch buffers, `find-tag' has another
  220. similar command that displays the new buffer in another window.  `C-x 4
  221. .' invokes the function `find-tag-other-window'.  (This key sequence
  222. ends with a period.)
  223.    Emacs comes with a tag table file `TAGS', in the directory
  224. containing Lisp libraries, which includes all the Lisp libraries and
  225. all the C sources of Emacs.  By specifying this file with
  226. `visit-tags-table' and then using `M-.' you can quickly look at the
  227. source of any Emacs function.
  228. File: emacs,  Node: Tags Search,  Next: Tags Stepping,  Prev: Find Tag,  Up: Tags
  229. Searching and Replacing with Tag Tables
  230. ---------------------------------------
  231.    The commands in this section visit and search all the files listed
  232. in the selected tag table, one by one.  For these commands, the tag
  233. table serves only to specify a sequence of files to search.  A related
  234. command is `M-x grep' (*note Compilation::.).
  235. `M-x tags-search'
  236.      Search for the specified regexp through the files in the selected
  237.      tag table.
  238. `M-x tags-query-replace'
  239.      Perform a `query-replace' on each file in the selected tag table.
  240. `M-,'
  241.      Restart one of the commands above, from the current location of
  242.      point (`tags-loop-continue').
  243.    `M-x tags-search' reads a regexp using the minibuffer, then visits
  244. the files of the selected tag table one by one, and searches through
  245. each one for that regexp.  It displays the name of the file being
  246. searched so you can follow its progress.  As soon as an occurrence is
  247. found, `tags-search' returns.
  248.    Having found one match, you probably want to find all the rest.  To
  249. find one more match, type `M-,' (`tags-loop-continue') to resume the
  250. `tags-search'.  This searches the rest of the current buffer, followed
  251. by the remaining files of the tag table.
  252.    `M-x tags-query-replace' performs a single `query-replace' through
  253. all the files in the tag table.  It reads a string to search for and a
  254. string to replace with, just like ordinary `M-x query-replace'.  It
  255. searches much like `M-x tags-search' but repeatedly, processing
  256. matches according to your input.  *Note Replace::, for more
  257. information on `query-replace'.
  258.    It is possible to get through all the files in the tag table with a
  259. single invocation of `M-x tags-query-replace'.  But since any
  260. unrecognized character causes the command to exit, you may need to
  261. continue where you left off.  `M-,' can be used for this.  It resumes
  262. the last tags search or replace command that you did.
  263.    It may have struck you that `tags-search' is a lot like `grep'. 
  264. You can also run `grep' itself as an inferior of Emacs and have Emacs
  265. show you the matching lines one by one.  This works mostly the same as
  266. running a compilation and having Emacs show you where the errors were. 
  267. *Note Compilation::.
  268. File: emacs,  Node: Tags Stepping,  Next: List Tags,  Prev: Tags Search,  Up: Tags
  269. Stepping Through a Tag Table
  270. ----------------------------
  271.    If you wish to process all the files in the selected tag table, but
  272. `M-x tags-search' and `M-x tags-query-replace' in particular are not
  273. what you want, you can use `M-x next-file'.
  274. `C-u M-x next-file'
  275.      With a numeric argument, regardless of its value, visit the first
  276.      file in the tag table, and prepare to advance sequentially by
  277.      files.
  278. `M-x next-file'
  279.      Visit the next file in the selected tag table.
  280. File: emacs,  Node: List Tags,  Prev: Tags Stepping,  Up: Tags
  281. Tag Table Inquiries
  282. -------------------
  283. `M-x list-tags'
  284.      Display a list of the tags defined in a specific program file.
  285. `M-x tags-apropos'
  286.      Display a list of all tags matching a specified regexp.
  287.    `M-x list-tags' reads the name of one of the files described by the
  288. selected tag table, and displays a list of all the tags defined in that
  289. file.  The "file name" argument is really just a string to compare
  290. against the names recorded in the tag table; it is read as a string
  291. rather than as a file name.  Therefore, completion and defaulting are
  292. not available, and you must enter the string the same way it appears
  293. in the tag table.  Do not include a directory as part of the file name
  294. unless the file name recorded in the tag table includes a directory.
  295.    `M-x tags-apropos' is like `apropos' for tags.  It reads a regexp,
  296. then finds all the tags in the selected tag table whose entries match
  297. that regexp, and displays the tag names found.
  298. File: emacs,  Node: Fortran,  Prev: Tags,  Up: Programs
  299. Fortran Mode
  300. ============
  301.    Fortran mode provides special motion commands for Fortran
  302. statements and subprograms, and indentation commands that understand
  303. Fortran conventions of nesting, line numbers and continuation
  304. statements.
  305.    Special commands for comments are provided because Fortran comments
  306. are unlike those of other languages.
  307.    Built-in abbrevs optionally save typing when you insert Fortran
  308. keywords.
  309.    Use `M-x fortran-mode' to switch to this major mode.  Doing so calls
  310. the value of `fortran-mode-hook' as a function of no arguments if that
  311. variable has a value that is not `nil'.
  312. * Menu:
  313. * Motion: Fortran Motion.     Moving point by statements or subprograms.
  314. * Indent: Fortran Indent.     Indentation commands for Fortran.
  315. * Comments: Fortran Comments. Inserting and aligning comments.
  316. * Columns: Fortran Columns.   Measuring columns for valid Fortran.
  317. * Abbrev: Fortran Abbrev.     Built-in abbrevs for Fortran keywords.
  318.    Fortran mode was contributed by Michael Prange.
  319. File: emacs,  Node: Fortran Motion,  Next: Fortran Indent,  Prev: Fortran,  Up: Fortran
  320. Motion Commands
  321. ---------------
  322.    Fortran mode provides special commands to move by subprograms
  323. (functions and subroutines) and by statements.  There is also a
  324. command to put the region around one subprogram, convenient for
  325. killing it or moving it.
  326. `C-M-a'
  327.      Move to beginning of subprogram
  328.       (`beginning-of-fortran-subprogram').
  329. `C-M-e'
  330.      Move to end of subprogram (`end-of-fortran-subprogram').
  331. `C-M-h'
  332.      Put point at beginning of subprogram and mark at end
  333.      (`mark-fortran-subprogram').
  334. `C-c C-n'
  335.      Move to beginning of current or next statement
  336.      (`fortran-next-statement').
  337. `C-c C-p'
  338.      Move to beginning of current or previous statement
  339.      (`fortran-previous-statement').
  340. File: emacs,  Node: Fortran Indent,  Next: Fortran Comments,  Prev: Fortran Motion,  Up: Fortran
  341. Fortran Indentation
  342. -------------------
  343.    Special commands and features are needed for indenting Fortran code
  344. in order to make sure various syntactic entities (line numbers,
  345. comment line indicators and continuation line flags) appear in the
  346. columns that are required for standard Fortran.
  347. * Menu:
  348. * Commands: ForIndent Commands. Commands for indenting Fortran.
  349. * Numbers:  ForIndent Num.      How line numbers auto-indent.
  350. * Conv:     ForIndent Conv.     Conventions you must obey to avoid trouble.
  351. * Vars:     ForIndent Vars.     Variables controlling Fortran indent style.
  352. File: emacs,  Node: ForIndent Commands,  Next: ForIndent Num,  Prev: Fortran Indent,  Up: Fortran Indent
  353. Fortran Indentation Commands
  354. ............................
  355. `TAB'
  356.      Indent the current line (`fortran-indent-line').
  357. `M-LFD'
  358.      Break the current line and set up a continuation line.
  359. `C-M-q'
  360.      Indent all the lines of the subprogram point is in
  361.      (`fortran-indent-subprogram').
  362.    TAB is redefined by Fortran mode to reindent the current line for
  363. Fortran (`fortran-indent-line').  Line numbers and continuation
  364. markers are indented to their required columns, and the body of the
  365. statement is independently indented based on its nesting in the
  366. program.
  367.    The key `C-M-q' is redefined as `fortran-indent-subprogram', a
  368. command to reindent all the lines of the Fortran subprogram (function
  369. or subroutine) containing point.
  370.    The key `M-LFD' is redefined as `fortran-split-line', a command to
  371. split a line in the appropriate fashion for Fortran.  In a non-comment
  372. line, the second half becomes a continuation line and is indented
  373. accordingly.  In a comment line, both halves become separate comment
  374. lines.
  375. File: emacs,  Node: ForIndent Num,  Next: ForIndent Conv,  Prev: ForIndent Commands,  Up: Fortran Indent
  376. Line Numbers and Continuation
  377. .............................
  378.    If a number is the first non-whitespace in the line, it is assumed
  379. to be a line number and is moved to columns 0 through 4.  (Columns are
  380. always counted from 0 in GNU Emacs.)  If the text on the line starts
  381. with the conventional Fortran continuation marker `$', it is moved to
  382. column 5.  If the text begins with any non whitespace character in
  383. column 5, it is assumed to be an unconventional continuation marker
  384. and remains in column 5.
  385.    Line numbers of four digits or less are normally indented one space. 
  386. This amount is controlled by the variable `fortran-line-number-indent'
  387. which is the maximum indentation a line number can have.  Line numbers
  388. are indented to right-justify them to end in column 4 unless that would
  389. require more than this maximum indentation.  The default value of the
  390. variable is 1.
  391.    Simply inserting a line number is enough to indent it according to
  392. these rules.  As each digit is inserted, the indentation is
  393. recomputed.  To turn off this feature, set the variable
  394. `fortran-electric-line-number' to `nil'.  Then inserting line numbers
  395. is like inserting anything else.
  396. File: emacs,  Node: ForIndent Conv,  Next: ForIndent Vars,  Prev: ForIndent Num,  Up: Fortran Indent
  397. Syntactic Conventions
  398. .....................
  399.    Fortran mode assumes that you follow certain conventions that
  400. simplify the task of understanding a Fortran program well enough to
  401. indent it properly:
  402.    * Two nested `do' loops never share a `continue' statement.
  403.    * The same character appears in column 5 of all continuation lines,
  404.      and this character is the value of the variable
  405.      `fortran-continuation-char'.  By default, this character is `$'.
  406. If you fail to follow these conventions, the indentation commands may
  407. indent some lines unaesthetically.  However, a correct Fortran program
  408. will retain its meaning when reindented even if the conventions are not
  409. followed.
  410. File: emacs,  Node: ForIndent Vars,  Prev: ForIndent Conv,  Up: Fortran Indent
  411. Variables for Fortran Indentation
  412. .................................
  413.    Several additional variables control how Fortran indentation works.
  414. `fortran-do-indent'
  415.      Extra indentation within each level of `do' statement (default 3).
  416. `fortran-if-indent'
  417.      Extra indentation within each level of `if' statement (default 3).
  418. `fortran-continuation-indent'
  419.      Extra indentation for bodies of continuation lines (default 5).
  420. `fortran-check-all-num-for-matching-do'
  421.      If this is `nil', indentation assumes that each `do' statement
  422.      ends on a `continue' statement.  Therefore, when computing
  423.      indentation for a statement other than `continue', it can save
  424.      time by not checking for a `do' statement ending there.  If this
  425.      is non-`nil', indenting any numbered statement must check for a
  426.      `do' that ends there.  The default is `nil'.
  427. `fortran-minimum-statement-indent'
  428.      Minimum indentation for fortran statements.  For standard Fortran,
  429.      this is 6.  Statement bodies will never be indented less than this
  430.      much.
  431. File: emacs,  Node: Fortran Comments,  Next: Fortran Columns,  Prev: Fortran Indent,  Up: Fortran
  432. Comments
  433. --------
  434.    The usual Emacs comment commands assume that a comment can follow a
  435. line of code.  In Fortran, the standard comment syntax requires an
  436. entire line to be just a comment.  Therefore, Fortran mode replaces
  437. the standard Emacs comment commands and defines some new variables.
  438.    Fortran mode can also handle a nonstandard comment syntax where
  439. comments start with `!' and can follow other text.  Because only some
  440. Fortran compilers accept this syntax, Fortran mode will not insert
  441. such comments unless you have said in advance to do so.  To do this,
  442. set the variable `comment-start' to `"!"' (*note Variables::.).
  443. `M-;'
  444.      Align comment or insert new comment (`fortran-comment-indent').
  445. `C-x ;'
  446.      Applies to nonstandard `!' comments only.
  447. `C-c ;'
  448.      Turn all lines of the region into comments, or (with arg) turn
  449.      them back into real code (`fortran-comment-region').
  450.    `M-;' in Fortran mode is redefined as the command
  451. `fortran-comment-indent'.  Like the usual `M-;' command, this
  452. recognizes any kind of existing comment and aligns its text
  453. appropriately; if there is no existing comment, a comment is inserted
  454. and aligned.  But inserting and aligning comments are not the same in
  455. Fortran mode as in other modes.
  456.    When a new comment must be inserted, if the current line is blank, a
  457. full-line comment is inserted.  On a non-blank line, a nonstandard `!'
  458. comment is inserted if you have said you want to use them.  Otherwise a
  459. full-line comment is inserted on a new line before the current line.
  460.    Nonstandard `!' comments are aligned like comments in other
  461. languages, but full-line comments are different.  In a standard
  462. full-line comment, the comment delimiter itself must always appear in
  463. column zero.  What can be aligned is the text within the comment.  You
  464. can choose from three styles of alignment by setting the variable
  465. `fortran-comment-indent-style' to one of these values:
  466. `fixed'
  467.      The text is aligned at a fixed column, which is the value of
  468.      `fortran-comment-line-column'.  This is the default.
  469. `relative'
  470.      The text is aligned as if it were a line of code, but with an
  471.      additional `fortran-comment-line-column' columns of indentation.
  472. `nil'
  473.      Text in full-line columns is not moved automatically.
  474.    In addition, you can specify the character to be used to indent
  475. within full-line comments by setting the variable
  476. `fortran-comment-indent-char' to the character you want to use.
  477.    Fortran mode introduces two variables `comment-line-start' and
  478. `comment-line-start-skip' which play for full-line comments the same
  479. roles played by `comment-start' and `comment-start-skip' for ordinary
  480. text-following comments.  Normally these are set properly by Fortran
  481. mode so you do not need to change them.
  482.    The normal Emacs comment command `C-x ;' has not been redefined. 
  483. If you use `!' comments, this command can be used with them.  Otherwise
  484. it is useless in Fortran mode.
  485.    The command `C-c ;' (`fortran-comment-region') turns all the lines
  486. of the region into comments by inserting the string `C$$$' at the
  487. front of each one.  With a numeric arg, the region is turned back into
  488. live code by deleting `C$$$' from the front of each line in it.  The
  489. string used for these comments can be controlled by setting the
  490. variable `fortran-comment-region'.  Note that here we have an example
  491. of a command and a variable with the same name; these two uses of the
  492. name never conflict because in Lisp and in Emacs it is always clear
  493. from the context which one is meant.
  494. File: emacs,  Node: Fortran Columns,  Next: Fortran Abbrev,  Prev: Fortran Comments,  Up: Fortran
  495. Columns
  496. -------
  497. `C-c C-r'
  498.      Displays a "column ruler" momentarily above the current line
  499.      (`fortran-column-ruler').
  500. `C-c C-w'
  501.      Splits the current window horizontally so that it is 72 columns
  502.      wide.  This may help you avoid going over that limit
  503.      (`fortran-window-create').
  504.    The command `C-c C-r' (`fortran-column-ruler') shows a column ruler
  505. momentarily above the current line.  The comment ruler is two lines of
  506. text that show you the locations of columns with special significance
  507. in Fortran programs.  Square brackets show the limits of the columns
  508. for line numbers, and curly brackets show the limits of the columns
  509. for the statement body.  Column numbers appear above them.
  510.    Note that the column numbers count from zero, as always in GNU
  511. Emacs.  As a result, the numbers may not be those you are familiar
  512. with; but the actual positions in the line are standard Fortran.
  513.    The text used to display the column ruler is the value of the
  514. variable `fortran-comment-ruler'.  By changing this variable, you can
  515. change the display.
  516.    For even more help, use `C-c C-w' (`fortran-window-create'), a
  517. command which splits the current window horizontally, making a window
  518. 72 columns wide.  By editing in this window you can immediately see
  519. when you make a line too wide to be correct Fortran.
  520. File: emacs,  Node: Fortran Abbrev,  Prev: Fortran Columns,  Up: Fortran
  521. Fortran Keyword Abbrevs
  522. -----------------------
  523.    Fortran mode provides many built-in abbrevs for common keywords and
  524. declarations.  These are the same sort of abbrev that you can define
  525. yourself.  To use them, you must turn on Abbrev mode.  *note
  526. Abbrevs::..
  527.    The built-in abbrevs are unusual in one way: they all start with a
  528. semicolon.  You cannot normally use semicolon in an abbrev, but Fortran
  529. mode makes this possible by changing the syntax of semicolon to "word
  530. constituent".
  531.    For example, one built-in Fortran abbrev is `;c' for `continue'. 
  532. If you insert `;c' and then insert a punctuation character such as a
  533. space or a newline, the `;c' will change automatically to `continue',
  534. provided Abbrev mode is enabled.
  535.    Type `;?' or `;C-h' to display a list of all the built-in Fortran
  536. abbrevs and what they stand for.
  537. File: emacs,  Node: Running,  Next: Abbrevs,  Prev: Programs,  Up: Top
  538. Compiling and Testing Programs
  539. ******************************
  540.    The previous chapter discusses the Emacs commands that are useful
  541. for making changes in programs.  This chapter deals with commands that
  542. assist in the larger process of developing and maintaining programs.
  543. * Menu:
  544. * Compilation::        Compiling programs in languages other than Lisp
  545.                         (C, Pascal, etc.)
  546. * Modes: Lisp Modes.   Various modes for editing Lisp programs, with
  547.                        different facilities for running the Lisp programs.
  548. * Libraries: Lisp Libraries.      Creating Lisp programs to run in Emacs.
  549. * Interaction: Lisp Interaction.  Executing Lisp in an Emacs buffer.
  550. * Eval: Lisp Eval.     Executing a single Lisp expression in Emacs.
  551. * Debug: Lisp Debug.   Debugging Lisp programs running in Emacs.
  552. * External Lisp::      Communicating through Emacs with a separate Lisp.
  553. File: emacs,  Node: Compilation,  Next: Lisp Modes,  Prev: Running,  Up: Running
  554. Running `make', or Compilers Generally
  555. ======================================
  556.    Emacs can run compilers for noninteractive languages such as C and
  557. Fortran as inferior processes, feeding the error log into an Emacs
  558. buffer.  It can also parse the error messages and visit the files in
  559. which errors are found, moving point right to the line where the error
  560. occurred.
  561. `M-x compile'
  562.      Run a compiler asynchronously under Emacs, with error messages to
  563.      `*compilation*' buffer.
  564. `M-x grep'
  565.      Run `grep' asynchronously under Emacs, with matching lines listed
  566.      in the buffer named `*compilation*'.
  567. `M-x kill-compiler'
  568. `M-x kill-grep'
  569.      Kill the running compilation or `grep' subprocess.
  570. `C-x `'
  571.      Visit the locus of the next compiler error message or `grep'
  572.      match.
  573.    To run `make' or another compiler, do `M-x compile'.  This command
  574. reads a shell command line using the minibuffer, and then executes the
  575. specified command line in an inferior shell with output going to the
  576. buffer named `*compilation*'.  The current buffer's default directory
  577. is used as the working directory for the execution of the command;
  578. normally, therefore, the makefile comes from this directory.
  579.    When the shell command line is read, the minibuffer appears
  580. containing a default command line, which is the command you used the
  581. last time you did `M-x compile'.  If you type just RET, the same
  582. command line is used again.  The first `M-x compile' provides `make
  583. -k' as the default.  The default is taken from the variable
  584. `compile-command'; if the appropriate compilation command for a file
  585. is something other than `make -k', it can be useful to have the file
  586. specify a local value for `compile-command' (*note File Variables::.).
  587.    Starting a compilation causes the buffer `*compilation*' to be
  588. displayed in another window but not selected.  Its mode line tells you
  589. whether compilation is finished, with the word `run' or `exit' inside
  590. the parentheses.  You do not have to keep this buffer visible;
  591. compilation continues in any case.
  592.    To kill the compilation process, do `M-x kill-compilation'.  You
  593. will see that the mode line of the `*compilation*' buffer changes to
  594. say `signal' instead of `run'.  Starting a new compilation also kills
  595. any running compilation, as only one can exist at any time.  However,
  596. this requires confirmation before actually killing a compilation that
  597. is running.
  598.    To parse the compiler error messages, type `C-x `' (`next-error'). 
  599. The character following the `C-x' is the grave accent, not the single
  600. quote.  This command displays the buffer `*compilation*' in one window
  601. and the buffer in which the next error occurred in another window. 
  602. Point in that buffer is moved to the line where the error was found. 
  603. The corresponding error message is scrolled to the top of the window
  604. in which `*compilation*' is displayed.
  605.    The first time `C-x `' is used after the start of a compilation, it
  606. parses all the error messages, visits all the files that have error
  607. messages, and makes markers pointing at the lines that the error
  608. messages refer to.  Then it moves to the first error message location.
  609.  Subsequent uses of `C-x `' advance down the data set up by the first
  610. use.  When the preparsed error messages are exhausted, the next `C-x
  611. `' checks for any more error messages that have come in; this is
  612. useful if you start editing the compiler errors while the compilation
  613. is still going on.  If no more error messages have come in, `C-x `'
  614. reports an error.
  615.    `C-u C-x `' discards the preparsed error message data and parses the
  616. `*compilation*' buffer over again, then displaying the first error. 
  617. This way, you can process the same set of errors again.
  618.    Instead of running a compiler, you can run `grep' and see the lines
  619. on which matches were found.  To do this, type `M-x grep' with an
  620. argument line that contains the same arguments you would give `grep'
  621. when running it normally: a `grep'-style regexp (usually in
  622. singlequotes to quote the shell's special characters) followed by
  623. filenames which may use wildcards.  The output from `grep' goes in the
  624. `*compilation*' buffer and the lines that matched can be found with
  625. `C-x `' as if they were compilation errors.
  626.    Note: a shell is used to run the compile command, but the shell is
  627. told that it should be noninteractive.  This means in particular that
  628. the shell starts up with no prompt.  If you find your usual shell
  629. prompt making an unsightly appearance in the `*compilation*' buffer,
  630. it means you have made a mistake in your shell's init file (`.cshrc'
  631. or `.shrc' or ...) by setting the prompt unconditionally.  The shell
  632. init file should set the prompt only if there already is a prompt.  In
  633. `csh', here is how to do it:
  634.      if ($?prompt) set prompt = ...
  635. File: emacs,  Node: Lisp Modes,  Next: Lisp Libraries,  Prev: Compilation,  Up: Running
  636. Major Modes for Lisp
  637. ====================
  638.    Emacs has four different major modes for Lisp.  They are the same in
  639. terms of editing commands, but differ in the commands for executing
  640. Lisp expressions.
  641. Emacs-Lisp mode
  642.      The mode for editing source files of programs to run in Emacs
  643.      Lisp.  This mode defines `C-M-x' to evaluate the current defun. 
  644.      *Note Lisp Libraries::.
  645. Lisp Interaction mode
  646.      The mode for an interactive session with Emacs Lisp.  It defines
  647.      LFD to evaluate the sexp before point and insert its value in the
  648.      buffer.  *Note Lisp Interaction::.
  649. Lisp mode
  650.      The mode for editing source files of programs that run in Lisps
  651.      other than Emacs Lisp.  This mode defines `C-M-x' to send the
  652.      current defun to an inferior Lisp process.  *Note External Lisp::.
  653. Inferior Lisp mode
  654.      The mode for an interactive session with an inferior Lisp process. 
  655.      This mode combines the special features of Lisp mode and Shell
  656.      mode (*note Shell Mode::.).
  657. Scheme mode
  658.      Like Lisp mode but for Scheme programs.
  659. Inferior Scheme mode
  660.      The mode for an interactive session with an inferior Scheme
  661.      process.
  662. File: emacs,  Node: Lisp Libraries,  Next: Lisp Eval,  Prev: Lisp Modes,  Up: Running
  663. Libraries of Lisp Code for Emacs
  664. ================================
  665.    Lisp code for Emacs editing commands is stored in files whose names
  666. conventionally end in `.el'.  This ending tells Emacs to edit them in
  667. Emacs-Lisp mode (*note Lisp Modes::.).
  668. * Menu:
  669. * Loading::        Loading libraries of Lisp code into Emacs for use.
  670. * Compiling Libraries:: Compiling a library makes it load and run faster.
  671. * Mocklisp::        Converting Mocklisp to Lisp so GNU Emacs can run it.
  672. File: emacs,  Node: Loading,  Next: Compiling Libraries,  Prev: Lisp Libraries,  Up: Lisp Libraries
  673. Loading Libraries
  674. -----------------
  675.    To execute a file of Emacs Lisp, use `M-x load-file'.  This command
  676. reads a file name using the minibuffer and then executes the contents
  677. of that file as Lisp code.  It is not necessary to visit the file
  678. first; in any case, this command reads the file as found on disk, not
  679. text in an Emacs buffer.
  680.    Once a file of Lisp code is installed in the Emacs Lisp library
  681. directories, users can load it using `M-x load-library'.  Programs can
  682. load it by calling `load-library', or with `load', a more primitive
  683. function that is similar but accepts some additional arguments.
  684.    `M-x load-library' differs from `M-x load-file' in that it searches
  685. a sequence of directories and tries three file names in each
  686. directory.  The three names are, first, the specified name with `.elc'
  687. appended; second, with `.el' appended; third, the specified name
  688. alone.  A `.elc' file would be the result of compiling the Lisp file
  689. into byte code; it is loaded if possible in preference to the Lisp
  690. file itself because the compiled file will load and run faster.
  691.    Because the argument to `load-library' is usually not in itself a
  692. valid file name, file name completion is not available.  Indeed, when
  693. using this command, you usually do not know exactly what file name
  694. will be used.
  695.    The sequence of directories searched by `M-x load-library' is
  696. specified by the variable `load-path', a list of strings that are
  697. directory names.  The default value of the list contains the directory
  698. where the Lisp code for Emacs itself is stored.  If you have libraries
  699. of your own, put them in a single directory and add that directory to
  700. `load-path'.  `nil' in this list stands for the current default
  701. directory, but it is probably not a good idea to put `nil' in the
  702. list.  If you find yourself wishing that `nil' were in the list, most
  703. likely what you really want to do is use `M-x load-file' this once.
  704.    Often you do not have to give any command to load a library,
  705. because the commands defined in the library are set up to "autoload"
  706. that library.  Running any of those commands causes `load' to be
  707. called to load the library; this replaces the autoload definitions
  708. with the real ones from the library.
  709.    If autoloading a file does not finish, either because of an error or
  710. because of a `C-g' quit, all function definitions made by the file are
  711. undone automatically.  So are any calls to `provide'.  As a
  712. consequence, if you use one of the autoloadable commands again, the
  713. entire file will be loaded a second time.  This prevents problems
  714. where the command is no longer autoloading but it works wrong because
  715. not all the file was loaded.  Function definitions are undone only for
  716. autoloading; explicit calls to `load' do not undo anything if loading
  717. is not completed.
  718. File: emacs,  Node: Compiling Libraries,  Next: Mocklisp,  Prev: Loading,  Up: Lisp Libraries
  719. Compiling Libraries
  720. -------------------
  721.    Emacs Lisp code can be compiled into byte-code which loads faster,
  722. takes up less space when loaded, and executes faster.
  723.    The way to make a byte-code compiled file from an Emacs-Lisp source
  724. file is with `M-x byte-compile-file'.  The default argument for this
  725. function is the file visited in the current buffer.  It reads the
  726. specified file, compiles it into byte code, and writes an output file
  727. whose name is made by appending `c' to the input file name.  Thus, the
  728. file `rmail.el' would be compiled into `rmail.elc'.
  729.    To recompile the changed Lisp files in a directory, use `M-x
  730. byte-recompile-directory'.  Specify just the directory name as an
  731. argument.  Each `.el' file that has been byte-compiled before is
  732. byte-compiled again if it has changed since the previous compilation. 
  733. A numeric argument to this command tells it to offer to compile each
  734. `.el' file that has not already been compiled.  You must answer `y' or
  735. `n' to each offer.
  736.    Emacs can be invoked noninteractively from the shell to do byte
  737. compilation with the aid of the function `batch-byte-compile'.  In
  738. this case, the files to be compiled are specified with command-line
  739. arguments.  Use a shell command of the form
  740.      emacs -batch -f batch-byte-compile FILES...
  741.    Directory names may also be given as arguments;
  742. `byte-recompile-directory' is invoked (in effect) on each such
  743. directory.  `batch-byte-compile' uses all the remaining command-line
  744. arguments as file or directory names, then kills the Emacs process.
  745.    `M-x disassemble' explains the result of byte compilation.  Its
  746. argument is a function name.  It displays the byte-compiled code in a
  747. help window in symbolic form, one instruction per line.  If the
  748. instruction refers to a variable or constant, that is shown too.
  749. File: emacs,  Node: Mocklisp,  Prev: Compiling Libraries,  Up: Lisp Libraries
  750. Converting Mocklisp to Lisp
  751. ---------------------------
  752.    GNU Emacs can run Mocklisp files by converting them to Emacs Lisp
  753. first.  To convert a Mocklisp file, visit it and then type `M-x
  754. convert-mocklisp-buffer'.  Then save the resulting buffer of Lisp file
  755. in a file whose name ends in `.el' and use the new file as a Lisp
  756. library.
  757.    It does not currently work to byte-compile converted Mocklisp code. 
  758. This is because converted Mocklisp code uses some special Lisp features
  759. to deal with Mocklisp's incompatible ideas of how arguments are
  760. evaluated and which values signify "true" or "false".
  761. File: emacs,  Node: Lisp Eval,  Next: Lisp Debug,  Prev: Lisp Libraries,  Up: Running
  762. Evaluating Emacs-Lisp Expressions
  763. =================================
  764.    Lisp programs intended to be run in Emacs should be edited in
  765. Emacs-Lisp mode; this will happen automatically for file names ending
  766. in `.el'.  By contrast, Lisp mode itself is used for editing Lisp
  767. programs intended for other Lisp systems.  Emacs-Lisp mode can be
  768. selected with the command `M-x emacs-lisp-mode'.
  769.    For testing of Lisp programs to run in Emacs, it is useful to be
  770. able to evaluate part of the program as it is found in the Emacs
  771. buffer.  For example, after changing the text of a Lisp function
  772. definition, evaluating the definition installs the change for future
  773. calls to the function.  Evaluation of Lisp expressions is also useful
  774. in any kind of editing task for invoking noninteractive functions
  775. (functions that are not commands).
  776. `M-ESC'
  777.      Read a Lisp expression in the minibuffer, evaluate it, and print
  778.      the value in the minibuffer (`eval-expression').
  779. `C-x C-e'
  780.      Evaluate the Lisp expression before point, and print the value in
  781.      the minibuffer (`eval-last-sexp').
  782. `C-M-x'
  783.      Evaluate the defun containing or after point, and print the value
  784.      in the minibuffer (`eval-defun').
  785. `M-x eval-region'
  786.      Evaluate all the Lisp expressions in the region.
  787. `M-x eval-current-buffer'
  788.      Evaluate all the Lisp expressions in the buffer.
  789.    `M-ESC' (`eval-expression') is the most basic command for evaluating
  790. a Lisp expression interactively.  It reads the expression using the
  791. minibuffer, so you can execute any expression on a buffer regardless of
  792. what the buffer contains.  When the expression is evaluated, the
  793. current buffer is once again the buffer that was current when `M-ESC'
  794. was typed.
  795.    `M-ESC' can easily confuse users who do not understand it,
  796. especially on keyboards with autorepeat where it can result from
  797. holding down the ESC key for too long.  Therefore, `eval-expression' is
  798. normally a disabled command.  Attempting to use this command asks for
  799. confirmation and gives you the option of enabling it; once you enable
  800. the command, confirmation will no longer be required for it.  *Note
  801. Disabling::.
  802.    In Emacs-Lisp mode, the key `C-M-x' is bound to the function
  803. `eval-defun', which parses the defun containing or following point as
  804. a Lisp expression and evaluates it.  The value is printed in the echo
  805. area.  This command is convenient for installing in the Lisp
  806. environment changes that you have just made in the text of a function
  807. definition.
  808.    The command `C-x C-e' (`eval-last-sexp') performs a similar job but
  809. is available in all major modes, not just Emacs-Lisp mode.  It finds
  810. the sexp before point, reads it as a Lisp expression, evaluates it, and
  811. prints the value in the echo area.  It is sometimes useful to type in
  812. an expression and then, with point still after it, type `C-x C-e'.
  813.    If `C-M-x' or `C-x C-e' is given a numeric argument, it prints the
  814. value by insertion into the current buffer at point, rather than in
  815. the echo area.  The argument value does not matter.
  816.    The most general command for evaluating Lisp expressions from a
  817. buffer is `eval-region'.  `M-x eval-region' parses the text of the
  818. region as one or more Lisp expressions, evaluating them one by one. 
  819. `M-x eval-current-buffer' is similar but evaluates the entire buffer. 
  820. This is a reasonable way to install the contents of a file of Lisp
  821. code that you are just ready to test.  After finding and fixing a bug,
  822. use `C-M-x' on each function that you change, to keep the Lisp world
  823. in step with the source file.
  824.